package com.sreader.sreader4j;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;

import com.sreader.interfaces.Feuille;
import com.vaadin.data.Validator;
import com.vaadin.data.validator.RegexpValidator;
import com.vaadin.event.FieldEvents.TextChangeEvent;
import com.vaadin.event.FieldEvents.TextChangeListener;
import com.vaadin.ui.AbsoluteLayout;
import com.vaadin.ui.CustomComponent;
import com.vaadin.ui.Form;
import com.vaadin.ui.Label;
import com.vaadin.ui.Panel;
import com.vaadin.ui.TextField;
import com.vaadin.ui.Window;
import com.vaadin.ui.AbstractTextField.TextChangeEventMode;

public class FeuilleDeIdentite extends CustomComponent implements Feuille, Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private Window mainWindow;
	//private Window indentityWindow;
	//private final String LOCALEBASE = "FeuilleDeCalcul";
	//private final String LOCALEPROPSTRING = "properties";
	private Locale currentLocaleValue;
	private AbsoluteLayout mainLayout;
	private Panel mainPanel;
	private AbsoluteLayout mainPanelAbsoluteLayout;
	private Form feuilleForm;
	private AbsoluteLayout formAbsoluteLayout;
	//Identity values
	private TextField name_15;
	private TextField name_14;
	private TextField name_13;
	private TextField name_12;
	private TextField name_11;
	private TextField name_10;
	private TextField name_9;
	private TextField name_8;
	private TextField name_7;
	private TextField name_6;
	private TextField name_5;
	private TextField name_4;
	private TextField name_3;
	private TextField name_2;
	private TextField name_1;
	private Label     nameLabel;
	private TextField vorname_15;
	private TextField vorname_14;
	private TextField vorname_13;
	private TextField vorname_12;
	private TextField vorname_11;
	private TextField vorname_10;
	private TextField vorname_9;
	private TextField vorname_8;
	private TextField vorname_7;
	private TextField vorname_6;
	private TextField vorname_5;
	private TextField vorname_4;
	private TextField vorname_3;
	private TextField vorname_2;
	private TextField vorname_1;
	private Label     vornameLabel;
	private TextField day_1;
	private TextField day_2;
	private TextField month_1;
	private TextField month_2;
	private TextField year_1;
	private TextField year_2;
	private TextField year_3;
	private TextField year_4;
	private Label dateLabel;
	//end Identity values
	
	//Validators
	private Validator letterEntryValidator;
	private Validator numericEntryValidator;
	private Messages messages;
	//end validators
	
	
	public FeuilleDeIdentite(Locale defaultLocale, Window main){
		setCurrentLocaleValue(defaultLocale);
		setMessages(new Messages("FeuilleDeCalcul",defaultLocale));
		this.mainWindow = main;
		buildMainLayout();
		setCompositionRoot(mainLayout);
		//vorname_1.setCursorPosition(0);
	}

	public void setCurrentLocaleValue(Locale currentLocaleValue) {
		this.currentLocaleValue = currentLocaleValue;
	}
	
	public Messages getMessages() {
		return messages;
	}

	public void setMessages(Messages messages) {
		this.messages = messages;
	}
	public AbsoluteLayout buildMainLayout(){
		mainLayout = new AbsoluteLayout();
		mainLayout.setCaption(getMessages().getString("feuilleIdentiteDesc"));
		mainLayout.setImmediate(false);
		mainLayout.setWidth("670.0px"); 
		mainLayout.setHeight("410.0px"); 
		mainLayout.setMargin(false);
		feuilleForm = buildFeuilleForm();
		
		//mainPanel = buildMainPanel();
		//mainLayout.addComponent(mainPanel, "top:0.0px;left:0.0px;");
		mainLayout.addComponent(feuilleForm);
		
		return mainLayout;
	}
	
	public String getCurrentLocaleValue() {
		
		return "_" + currentLocaleValue.toString();
	}

	@Override
	public Panel buildMainPanel() {
		// TODO Auto-generated method stub
		// common part: create layout
		mainPanel = new Panel(getMessages().getString("feuilleCaption"));
		mainPanel.setImmediate(false);
		mainPanel.setWidth("650.0px"); //720.0
		mainPanel.setHeight("350px"); //900.0
				
		// mainPanelAbsoluteLayout
		mainPanelAbsoluteLayout = buildMainPanelAbsoluteLayout();
		mainPanel.setContent(mainPanelAbsoluteLayout);
		return mainPanel;
	}

	@Override
	public AbsoluteLayout buildMainPanelAbsoluteLayout() {
		feuilleForm = buildFeuilleForm();
		// common part: create layout
		mainPanelAbsoluteLayout = new AbsoluteLayout();
		mainPanelAbsoluteLayout.setImmediate(true);
		
		mainPanelAbsoluteLayout.setWidth("645.0px"); //715.0
		mainPanelAbsoluteLayout.setHeight("300.0px"); //870.0
		mainPanelAbsoluteLayout.setMargin(false);
		
		mainPanelAbsoluteLayout.addComponent(feuilleForm);
		
		return mainPanelAbsoluteLayout;
	}
	
	public Form buildFeuilleForm(){
		//common part. create layout
		feuilleForm = new Form();
		feuilleForm.setCaption(getMessages().getString("feuilleCaption")); //$NON-NLS-1$
		feuilleForm.setDescription(getMessages().getString("feuilleIdentiteDesc"));
		feuilleForm.setImmediate(true);
		feuilleForm.setWidth("630.0px"); //710.0
		feuilleForm.setHeight("250px"); //860.0
		//feuilleForm.setWriteThrough(false);
		
		
		//formAbsoluteLayout
		formAbsoluteLayout = buildFormAbsoluteLayout();
	
		
		feuilleForm.setLayout(formAbsoluteLayout);
		
		return feuilleForm;
	}

	@Override
	public AbsoluteLayout buildFormAbsoluteLayout() {
		// TODO Auto-generated method stub
		formAbsoluteLayout = new AbsoluteLayout();
		formAbsoluteLayout.setImmediate(true);
		formAbsoluteLayout.setWidth("620.0px"); //700.0
		formAbsoluteLayout.setHeight("230px"); //840.0$NON-NLS-1$
		formAbsoluteLayout.setMargin(false);
		
		//letterEntryValidator
		letterEntryValidator = new RegexpValidator("[a-zA-ZäöüßÄÖÜ]", getMessages().getString("letterValidator")); 
		//numericEntryValidator
		numericEntryValidator = new RegexpValidator("[0-9]",getMessages().getString("digitValidator")); 		
		
		//vornameLabel
		vornameLabel = new Label();
		vornameLabel.setCaption(getMessages().getString("firstname"));
		vornameLabel.setWidth("15px");
		formAbsoluteLayout.addComponent(vornameLabel, 
				"top:50.0px;left:10.0px;");
		
		// vorname_1
		vorname_1 = new TextField();
		vorname_1.setImmediate(true);
		vorname_1.setWidth("32px");
		vorname_1.setHeight("-1px");
		vorname_1.setTabIndex(1);
		vorname_1.setMaxLength(1);
		vorname_1.setTextChangeEventMode(TextChangeEventMode.EAGER);
		vorname_1.addListener(new TextChangeListener() {
		/**
		* 
		*/
		private static final long serialVersionUID = -2768316132190135628L;

		@Override
		public void textChange(TextChangeEvent event) {
			// TODO Auto-generated method stub
			//AbstractTextField source = (AbstractTextField) event.getSource();
			if(event.getText().length()>0){
				vorname_2.focus();
			}
			if(event.getText().length()==0){
				event.getComponent().setCaption("");
				event.getComponent().requestRepaint();
			}
		}
		});

		vorname_1.addValidator(letterEntryValidator);
		formAbsoluteLayout.addComponent(vorname_1,
				"top:35.0px;left:87.0px;");
		
		// vorname_2
				vorname_2 = new TextField();
				vorname_2.setImmediate(true);
				vorname_2.setTextChangeEventMode(TextChangeEventMode.EAGER);
				vorname_2.addListener(new TextChangeListener() {
					
					/**
					 * 
					 */
					private static final long serialVersionUID = 1L;

					@Override
					public void textChange(TextChangeEvent event) {
						// TODO Auto-generated method stub
						if(event.getText().length()>0){
							vorname_3.focus();
						}
						if(event.getText().length()==0){
							event.getComponent().setCaption("");
							event.getComponent().requestRepaint();
						}
					}
				});
				vorname_2.setWidth("32px"); 
				vorname_2.setHeight("-1px"); 
				vorname_2.setTabIndex(2);
				vorname_2.setMaxLength(1);
				vorname_2.addValidator(letterEntryValidator);
				formAbsoluteLayout.addComponent(vorname_2,
						"top:35.0px;left:117.0px;");
				
				// vorname_3
				vorname_3 = new TextField();
				vorname_3.setImmediate(true);
				vorname_3.setTextChangeEventMode(TextChangeEventMode.EAGER);
				vorname_3.addListener(new TextChangeListener() {
					
					/**
					 * 
					 */
					private static final long serialVersionUID = 1L;

					@Override
					public void textChange(TextChangeEvent event) {
						// TODO Auto-generated method stub
						if(event.getText().length()>0){
							vorname_4.focus();
						}
						if(event.getText().length()==0){
							event.getComponent().setCaption("");
							event.getComponent().requestRepaint();
						}
					}
				});
				vorname_3.setWidth("32px"); 
				vorname_3.setHeight("-1px"); 
				vorname_3.setTabIndex(3);
				vorname_3.setMaxLength(1);
				vorname_3.addValidator(letterEntryValidator);
				formAbsoluteLayout.addComponent(vorname_3,
						"top:35.0px;left:149.0px;"); 
				
				// vorname_4
				vorname_4 = new TextField();
				vorname_4.setImmediate(true);
				vorname_4.setTextChangeEventMode(TextChangeEventMode.EAGER);
				vorname_4.addListener(new TextChangeListener() {
					
					/**
					 * 
					 */
					private static final long serialVersionUID = 1L;

					@Override
					public void textChange(TextChangeEvent event) {
						// TODO Auto-generated method stub
						if(event.getText().length()>0){
							vorname_5.focus();
						}
						if(event.getText().length()==0){
							event.getComponent().setCaption("");
							event.getComponent().requestRepaint();
						}
					}
				});
				vorname_4.setWidth("32px"); 
				vorname_4.setHeight("-1px"); 
				vorname_4.setTabIndex(4);
				vorname_4.setMaxLength(1);
				vorname_4.addValidator(letterEntryValidator);
				formAbsoluteLayout.addComponent(vorname_4,
						"top:35.0px;left:179.0px;"); 
				
				// vorname_5
				vorname_5 = new TextField();
				vorname_5.setImmediate(true);
				vorname_5.setTextChangeEventMode(TextChangeEventMode.EAGER);
				vorname_5.addListener(new TextChangeListener(){
					
					/**
					 * 
					 */
					private static final long serialVersionUID = 1L;

					@Override
					public void textChange(TextChangeEvent event) {
						// TODO Auto-generated method stub
						if(event.getText().length()>0){
							vorname_6.focus();
						}
						if(event.getText().length()==0){
							event.getComponent().setCaption("");
							event.getComponent().requestRepaint();
						}
					}
				});
				vorname_5.setWidth("32px"); 
				vorname_5.setHeight("-1px"); 
				vorname_5.setTabIndex(5);
				vorname_5.setMaxLength(1);
				vorname_5.addValidator(letterEntryValidator);
				formAbsoluteLayout.addComponent(vorname_5,
						"top:35.0px;left:211.0px;"); 
				
				// vorname_6
				vorname_6 = new TextField();
				vorname_6.setImmediate(true);
				vorname_6.setTextChangeEventMode(TextChangeEventMode.EAGER);
				vorname_6.addListener(new TextChangeListener() {
					
					/**
					 * 
					 */
					private static final long serialVersionUID = 1L;

					@Override
					public void textChange(TextChangeEvent event) {
						// TODO Auto-generated method stub
						if(event.getText().length()>0){
							vorname_7.focus();
						}
						if(event.getText().length()==0){
							event.getComponent().setCaption("");
							event.getComponent().requestRepaint();
						}
					}
				});
				vorname_6.setWidth("32px"); 
				vorname_6.setHeight("-1px"); 
				vorname_6.setTabIndex(6);
				vorname_6.setMaxLength(1);
				vorname_6.addValidator(letterEntryValidator);
				formAbsoluteLayout.addComponent(vorname_6,
						"top:35.0px;left:242.0px;"); 
				
				// vorname_7
				vorname_7 = new TextField();
				vorname_7.setImmediate(true);
				vorname_7.setTextChangeEventMode(TextChangeEventMode.EAGER);
				vorname_7.addListener(new TextChangeListener() {
					
					/**
					 * 
					 */
					private static final long serialVersionUID = 1L;

					@Override
					public void textChange(TextChangeEvent event) {
						// TODO Auto-generated method stub
						if(event.getText().length()>0){
							vorname_8.focus();
						}
						if(event.getText().length()==0){
							event.getComponent().setCaption("");
							event.getComponent().requestRepaint();
						}
					}
				});
				vorname_7.setWidth("32px"); 
				vorname_7.setHeight("-1px"); 
				vorname_7.setTabIndex(7);
				vorname_7.setMaxLength(1);
				vorname_7.addValidator(letterEntryValidator);
				formAbsoluteLayout.addComponent(vorname_7,
						"top:35.0px;left:273.0px;"); 
				
				// vorname_8
				vorname_8 = new TextField();
				vorname_8.setImmediate(true);
				vorname_8.setTextChangeEventMode(TextChangeEventMode.EAGER);
				vorname_8.addListener(new TextChangeListener() {
					
					/**
					 * 
					 */
					private static final long serialVersionUID = 1L;

					@Override
					public void textChange(TextChangeEvent event) {
						// TODO Auto-generated method stub
						if(event.getText().length()>0){
							vorname_9.focus();
						}
						if(event.getText().length()==0){
							event.getComponent().setCaption("");
							event.getComponent().requestRepaint();
						}
					}
				});
				vorname_8.setWidth("32px"); 
				vorname_8.setHeight("-1px"); 
				vorname_8.setTabIndex(8);
				vorname_8.setMaxLength(1);
				vorname_8.addValidator(letterEntryValidator);
				formAbsoluteLayout.addComponent(vorname_8,
						"top:35.0px;left:304.0px;");
				
				// vorname_9
				vorname_9 = new TextField();
				vorname_9.setImmediate(true);
				vorname_9.setTextChangeEventMode(TextChangeEventMode.EAGER);
				vorname_9.addListener(new TextChangeListener() {
					
					/**
					 * 
					 */
					private static final long serialVersionUID = 1L;

					@Override
					public void textChange(TextChangeEvent event) {
						// TODO Auto-generated method stub
						if(event.getText().length()>0){
							vorname_10.focus();
						}
						if(event.getText().length()==0){
							event.getComponent().setCaption("");
							event.getComponent().requestRepaint();
						}
					}
				});
				vorname_9.setWidth("32px"); 
				vorname_9.setHeight("-1px"); 
				vorname_9.setTabIndex(9);
				vorname_9.setMaxLength(1);
				vorname_9.addValidator(letterEntryValidator);
				formAbsoluteLayout.addComponent(vorname_9,
						"top:35.0px;left:336.0px;"); 
				
				// vorname_10
				vorname_10 = new TextField();
				vorname_10.setImmediate(true);
				vorname_10.setTextChangeEventMode(TextChangeEventMode.EAGER);
				vorname_10.addListener(new TextChangeListener() {
					
					/**
					 * 
					 */
					private static final long serialVersionUID = 1L;

					@Override
					public void textChange(TextChangeEvent event) {
						// TODO Auto-generated method stub
						if(event.getText().length()>0){
							vorname_11.focus();
						}
						if(event.getText().length()==0){
							event.getComponent().setCaption("");
							event.getComponent().requestRepaint();
						}
					}
				});
				vorname_10.setWidth("32px"); 
				vorname_10.setHeight("-1px"); 
				vorname_10.setTabIndex(10);
				vorname_10.setMaxLength(1);
				vorname_10.addValidator(letterEntryValidator);
				formAbsoluteLayout.addComponent(vorname_10,
						"top:35.0px;left:367.0px;"); 
				
				// vorname_11
				vorname_11 = new TextField();
				vorname_11.setImmediate(true);
				vorname_11.setTextChangeEventMode(TextChangeEventMode.EAGER);
				vorname_11.addListener(new TextChangeListener() {
					
					/**
					 * 
					 */
					private static final long serialVersionUID = 1L;

					@Override
					public void textChange(TextChangeEvent event) {
						// TODO Auto-generated method stub
						if(event.getText().length()>0){
							vorname_12.focus();
						}
						if(event.getText().length()==0){
							event.getComponent().setCaption("");
							event.getComponent().requestRepaint();
						}
					}
				});
				vorname_11.setWidth("32px"); 
				vorname_11.setHeight("-1px"); 
				vorname_11.setTabIndex(11);
				vorname_11.setMaxLength(1);
				vorname_11.addValidator(letterEntryValidator);
				formAbsoluteLayout.addComponent(vorname_11,
						"top:35.0px;left:397.0px;"); 
				
				// vorname_12
				vorname_12 = new TextField();
				vorname_12.setImmediate(true);
				vorname_12.setTextChangeEventMode(TextChangeEventMode.EAGER);
				vorname_12.addListener(new TextChangeListener() {
					
					/**
					 * 
					 */
					private static final long serialVersionUID = 1L;

					@Override
					public void textChange(TextChangeEvent event) {
						// TODO Auto-generated method stub
						if(event.getText().length()>0){
							vorname_13.focus();
						}
						if(event.getText().length()==0){
							event.getComponent().setCaption("");
							event.getComponent().requestRepaint();
						}
					}
				});
				vorname_12.setWidth("32px"); 
				vorname_12.setHeight("-1px"); 
				vorname_12.setTabIndex(12);
				vorname_12.setMaxLength(1);
				vorname_12.addValidator(letterEntryValidator);
				formAbsoluteLayout.addComponent(vorname_12,
						"top:35.0px;left:429.0px;"); 
				
				// vorname_13
				vorname_13 = new TextField();
				vorname_13.setImmediate(true);
				vorname_13.setTextChangeEventMode(TextChangeEventMode.EAGER);
				vorname_13.addListener(new TextChangeListener() {
					
					/**
					 * 
					 */
					private static final long serialVersionUID = 1L;

					@Override
					public void textChange(TextChangeEvent event) {
						// TODO Auto-generated method stub
						if(event.getText().length()>0){
							vorname_14.focus();
						}
						if(event.getText().length()==0){
							event.getComponent().setCaption("");
							event.getComponent().requestRepaint();
						}
					}
				});
				vorname_13.setWidth("32px"); 
				vorname_13.setHeight("-1px"); 
				vorname_13.setTabIndex(13);
				vorname_13.setMaxLength(1);
				vorname_13.addValidator(letterEntryValidator);
				formAbsoluteLayout.addComponent(vorname_13,
						"top:35.0px;left:461.0px;"); 
				
				// vorname_14
				vorname_14 = new TextField();
				vorname_14.setImmediate(true);
				vorname_14.setTextChangeEventMode(TextChangeEventMode.EAGER);
				vorname_14.addListener(new TextChangeListener() {
					
					/**
					 * 
					 */
					private static final long serialVersionUID = 1L;

					@Override
					public void textChange(TextChangeEvent event) {
						// TODO Auto-generated method stub
						if(event.getText().length()>0){
							vorname_15.focus();
						}
						if(event.getText().length()==0){
							event.getComponent().setCaption("");
							event.getComponent().requestRepaint();
						}
					}
				});
				vorname_14.setWidth("32px"); 
				vorname_14.setHeight("-1px"); 
				vorname_14.setTabIndex(14);
				vorname_14.setMaxLength(1);
				vorname_14.addValidator(letterEntryValidator);
				formAbsoluteLayout.addComponent(vorname_14,
						"top:35.0px;left:492.0px;"); 
				
				// vorname_15
				vorname_15 = new TextField();
				vorname_15.setImmediate(true);
				vorname_15.setTextChangeEventMode(TextChangeEventMode.EAGER);
				vorname_15.addListener(new TextChangeListener() {
					
					/**
					 * 
					 */
					private static final long serialVersionUID = 1L;

					@Override
					public void textChange(TextChangeEvent event) {
						// TODO Auto-generated method stub
						if(event.getText().length()>0){
							name_1.focus();
						}
						if(event.getText().length()==0){
							event.getComponent().setCaption("");
							event.getComponent().requestRepaint();
						}
					}
				});
				vorname_15.setWidth("32px"); 
				vorname_15.setHeight("-1px"); 
				vorname_15.setTabIndex(15);
				vorname_15.setMaxLength(1);
				vorname_15.addValidator(letterEntryValidator);
				formAbsoluteLayout.addComponent(vorname_15,
						"top:35.0px;left:523.0px;"); 
		
				//nameLabel
				nameLabel = new Label();
				nameLabel.setCaption(getMessages().getString("Name")); //$NON-NLS-1$
				nameLabel.setWidth("15px"); 
				formAbsoluteLayout.addComponent(nameLabel, 
						"top:94.0px;left:10.0px;"); 
				// name_1
				name_1 = new TextField();
				name_1.setImmediate(true);
				name_1.setTextChangeEventMode(TextChangeEventMode.EAGER);
				name_1.addListener(new TextChangeListener() {
					
					/**
					 * 
					 */
					private static final long serialVersionUID = 1L;

					@Override
					public void textChange(TextChangeEvent event) {
						// TODO Auto-generated method stub
						if(event.getText().length()>0){
							name_2.focus();
						}
						if(event.getText().length()==0){
							event.getComponent().setCaption("");
							event.getComponent().requestRepaint();
						}
					}
				});
				name_1.setWidth("32px"); 
				name_1.setHeight("-1px"); 
				name_1.setTabIndex(16);
				name_1.setMaxLength(1);
				name_1.addValidator(letterEntryValidator);
				formAbsoluteLayout
						.addComponent(name_1, "top:79.0px;left:87.0px;"); 
				
				// name_2
				name_2 = new TextField();
				name_2.setImmediate(true);
				name_2.setTextChangeEventMode(TextChangeEventMode.EAGER);
				name_2.addListener(new TextChangeListener() {
					
					/**
					 * 
					 */
					private static final long serialVersionUID = 1L;

					@Override
					public void textChange(TextChangeEvent event) {
						// TODO Auto-generated method stub
						if(event.getText().length()>0){
							name_3.focus();
						}
						if(event.getText().length()==0){
							event.getComponent().setCaption("");
							event.getComponent().requestRepaint();
						}
					}
				});
				name_2.setWidth("32px"); 
				name_2.setHeight("-1px"); 
				name_2.setTabIndex(17);
				name_2.setMaxLength(1);
				name_2.addValidator(letterEntryValidator);
				formAbsoluteLayout
						.addComponent(name_2, "top:79.0px;left:117.0px;"); //$NON-NLS-1$
				
				// name_3
				name_3 = new TextField();
				name_3.setImmediate(true);
				name_3.setTextChangeEventMode(TextChangeEventMode.EAGER);
				name_3.addListener(new TextChangeListener() {
					
					/**
					 * 
					 */
					private static final long serialVersionUID = 1L;

					@Override
					public void textChange(TextChangeEvent event) {
						// TODO Auto-generated method stub
						if(event.getText().length()>0){
							name_4.focus();
						}
						if(event.getText().length()==0){
							event.getComponent().setCaption("");
							event.getComponent().requestRepaint();
						}
					}
				});
				name_3.setWidth("32px"); 
				name_3.setHeight("-1px"); 
				name_3.setTabIndex(18);
				name_3.setMaxLength(1);
				name_3.addValidator(letterEntryValidator);
				formAbsoluteLayout.addComponent(name_3,
						"top:79.0px;left:149.0px;"); 
				
				// name_4
				name_4 = new TextField();
				name_4.setImmediate(true);
				name_4.setTextChangeEventMode(TextChangeEventMode.EAGER);
				name_4.addListener(new TextChangeListener() {
					
					/**
					 * 
					 */
					private static final long serialVersionUID = 1L;

					@Override
					public void textChange(TextChangeEvent event) {
						// TODO Auto-generated method stub
						if(event.getText().length()>0){
							name_5.focus();
						}
						if(event.getText().length()==0){
							event.getComponent().setCaption("");
							event.getComponent().requestRepaint();
						}
					}
				});
				name_4.setWidth("32px"); 
				name_4.setHeight("-1px"); 
				name_4.setTabIndex(19);
				name_4.setMaxLength(1);
				name_4.addValidator(letterEntryValidator);
				formAbsoluteLayout.addComponent(name_4,
						"top:79.0px;left:179.0px;"); 
				
				// name_5
				name_5 = new TextField();
				name_5.setImmediate(true);
				name_5.setTextChangeEventMode(TextChangeEventMode.EAGER);
				name_5.addListener(new TextChangeListener() {
					
					/**
					 * 
					 */
					private static final long serialVersionUID = 1L;

					@Override
					public void textChange(TextChangeEvent event) {
						// TODO Auto-generated method stub
						if(event.getText().length()>0){
							name_6.focus();
						}
						if(event.getText().length()==0){
							event.getComponent().setCaption("");
							event.getComponent().requestRepaint();
						}
					}
				});
				name_5.setWidth("32px"); 
				name_5.setHeight("-1px"); 
				name_5.setTabIndex(20);
				name_5.setMaxLength(1);
				name_5.addValidator(letterEntryValidator);
				formAbsoluteLayout.addComponent(name_5,
						"top:79.0px;left:211.0px;"); 
				
				// name_6
				name_6 = new TextField();
				name_6.setImmediate(true);
				name_6.setTextChangeEventMode(TextChangeEventMode.EAGER);
				name_6.addListener(new TextChangeListener() {
					
					/**
					 * 
					 */
					private static final long serialVersionUID = 1L;

					@Override
					public void textChange(TextChangeEvent event) {
						// TODO Auto-generated method stub
						if(event.getText().length()>0){
							name_7.focus();
						}
						if(event.getText().length()==0){
							event.getComponent().setCaption("");
							event.getComponent().requestRepaint();
						}
					}
				});
				name_6.setWidth("32px"); 
				name_6.setHeight("-1px");
				name_6.setTabIndex(21);
				name_6.setMaxLength(1);
				name_6.addValidator(letterEntryValidator);
				formAbsoluteLayout.addComponent(name_6,
						"top:79.0px;left:242.0px;"); 
				
				// name_7
				name_7 = new TextField();
				name_7.setImmediate(true);
				name_7.setTextChangeEventMode(TextChangeEventMode.EAGER);
				name_7.addListener(new TextChangeListener() {
					
					/**
					 * 
					 */
					private static final long serialVersionUID = 1L;

					@Override
					public void textChange(TextChangeEvent event) {
						// TODO Auto-generated method stub
						if(event.getText().length()>0){
							name_8.focus();
						}
						if(event.getText().length()==0){
							event.getComponent().setCaption("");
							event.getComponent().requestRepaint();
						}
					}
				});
				name_7.setWidth("32px"); 
				name_7.setHeight("-1px"); 
				name_7.setTabIndex(22);
				name_7.setMaxLength(1);
				name_7.addValidator(letterEntryValidator);
				formAbsoluteLayout.addComponent(name_7,
						"top:79.0px;left:273.0px;"); 
				
				// name_8
				name_8 = new TextField();
				name_8.setImmediate(true);
				name_8.setTextChangeEventMode(TextChangeEventMode.EAGER);
				name_8.addListener(new TextChangeListener() {
					
					/**
					 * 
					 */
					private static final long serialVersionUID = 1L;

					@Override
					public void textChange(TextChangeEvent event) {
						// TODO Auto-generated method stub
						if(event.getText().length()>0){
							name_9.focus();
						}
						if(event.getText().length()==0){
							event.getComponent().setCaption("");
							event.getComponent().requestRepaint();
						}
					}
				});
				name_8.setWidth("32px"); 
				name_8.setHeight("-1px"); 
				name_8.setTabIndex(23);
				name_8.setMaxLength(1);
				name_8.addValidator(letterEntryValidator);
				formAbsoluteLayout.addComponent(name_8,
						"top:79.0px;left:304.0px;"); 
				
				// name_9
				name_9 = new TextField();
				name_9.setImmediate(true);
				name_9.setTextChangeEventMode(TextChangeEventMode.EAGER);
				name_9.addListener(new TextChangeListener() {
					
					/**
					 * 
					 */
					private static final long serialVersionUID = 1L;

					@Override
					public void textChange(TextChangeEvent event) {
						// TODO Auto-generated method stub
						if(event.getText().length()>0){
							name_10.focus();
						}
						if(event.getText().length()==0){
							event.getComponent().setCaption("");
							event.getComponent().requestRepaint();
						}
					}
				});
				name_9.setWidth("32px"); 
				name_9.setHeight("-1px"); 
				name_9.setTabIndex(24);
				name_9.setMaxLength(1);
				name_9.addValidator(letterEntryValidator);
				formAbsoluteLayout.addComponent(name_9,
						"top:79.0px;left:336.0px;;"); 
				
				// name_10
				name_10 = new TextField();
				name_10.setImmediate(true);
				name_10.setTextChangeEventMode(TextChangeEventMode.EAGER);
				name_10.addListener(new TextChangeListener() {
					
					/**
					 * 
					 */
					private static final long serialVersionUID = 1L;

					@Override
					public void textChange(TextChangeEvent event) {
						// TODO Auto-generated method stub
						if(event.getText().length()>0){
							name_11.focus();
						}
						if(event.getText().length()==0){
							event.getComponent().setCaption("");
							event.getComponent().requestRepaint();
						}
					}
				});
				name_10.setWidth("32px"); 
				name_10.setHeight("-1px"); 
				name_10.setTabIndex(25);
				name_10.setMaxLength(1);
				name_10.addValidator(letterEntryValidator);
				formAbsoluteLayout.addComponent(name_10,
						"top:79.0px;left:367.0px;"); 
				
				// name_11
				name_11 = new TextField();
				name_11.setImmediate(true);
				name_11.setTextChangeEventMode(TextChangeEventMode.EAGER);
				name_11.addListener(new TextChangeListener() {
					
					/**
					 * 
					 */
					private static final long serialVersionUID = 1L;

					@Override
					public void textChange(TextChangeEvent event) {
						// TODO Auto-generated method stub
						if(event.getText().length()>0){
							name_12.focus();
						}
						if(event.getText().length()==0){
							event.getComponent().setCaption("");
							event.getComponent().requestRepaint();
						}
					}
				});
				name_11.setWidth("32px"); 
				name_11.setHeight("-1px"); 
				name_11.setTabIndex(26);
				name_11.setMaxLength(1);
				name_11.addValidator(letterEntryValidator);
				formAbsoluteLayout.addComponent(name_11,
						"top:79.0px;left:397.0px;"); 
				
				// name_12
				name_12 = new TextField();
				name_12.setImmediate(true);
				name_12.setTextChangeEventMode(TextChangeEventMode.EAGER);
				name_12.addListener(new TextChangeListener() {
					
					/**
					 * 
					 */
					private static final long serialVersionUID = 1L;

					@Override
					public void textChange(TextChangeEvent event) {
						// TODO Auto-generated method stub
						if(event.getText().length()>0){
							name_13.focus();
						}
						if(event.getText().length()==0){
							event.getComponent().setCaption("");
							event.getComponent().requestRepaint();
						}
					}
				});
				name_12.setWidth("32px"); 
				name_12.setHeight("-1px"); 
				name_12.setTabIndex(27);
				name_12.setMaxLength(1);
				name_12.addValidator(letterEntryValidator);
				formAbsoluteLayout.addComponent(name_12,
						"top:79.0px;left:429.0px;"); 
				
				// name_13
				name_13 = new TextField();
				name_13.setImmediate(true);
				name_13.setTextChangeEventMode(TextChangeEventMode.EAGER);
				name_13.addListener(new TextChangeListener() {
					
					/**
					 * 
					 */
					private static final long serialVersionUID = 1L;

					@Override
					public void textChange(TextChangeEvent event) {
						// TODO Auto-generated method stub
						if(event.getText().length()>0){
							name_14.focus();
						}
						if(event.getText().length()==0){
							event.getComponent().setCaption("");
							event.getComponent().requestRepaint();
						}
					}
				});
				name_13.setWidth("32px"); 
				name_13.setHeight("-1px");
				name_13.setTabIndex(28);
				name_13.setMaxLength(1);
				name_13.addValidator(letterEntryValidator);
				formAbsoluteLayout.addComponent(name_13,
						"top:79.0px;left:461.0px;"); 
				
				// name_14
				name_14 = new TextField();
				name_14.setImmediate(true);
				name_14.setTextChangeEventMode(TextChangeEventMode.EAGER);
				name_14.addListener(new TextChangeListener() {
					
					/**
					 * 
					 */
					private static final long serialVersionUID = 1L;

					@Override
					public void textChange(TextChangeEvent event) {
						// TODO Auto-generated method stub
						if(event.getText().length()>0){
							name_15.focus();
						}
						if(event.getText().length()==0){
							event.getComponent().setCaption("");
							event.getComponent().requestRepaint();
						}
						if(event.getText().length()==0){
							event.getComponent().setCaption("");
							event.getComponent().requestRepaint();
						}
					}
				});
				name_14.setWidth("32px"); 
				name_14.setHeight("-1px"); 
				name_14.setTabIndex(29);
				name_14.setMaxLength(1);
				name_14.addValidator(letterEntryValidator);
				formAbsoluteLayout.addComponent(name_14,
						"top:79.0px;left:492.0px;"); 
				
				// name_15
				name_15 = new TextField();
				name_15.setImmediate(true);
				name_15.setTextChangeEventMode(TextChangeEventMode.EAGER);
				name_15.addListener(new TextChangeListener() {
					
					/**
					 * 
					 */
					private static final long serialVersionUID = 1L;

					@Override
					public void textChange(TextChangeEvent event) {
						// TODO Auto-generated method stub
						if(event.getText().length()>0){
							day_1.focus();
						}
						if(event.getText().length()==0){
							event.getComponent().setCaption("");
							event.getComponent().requestRepaint();
						}
					}
				});
				name_15.setWidth("32px"); 
				name_15.setHeight("-1px"); 
				name_15.setTabIndex(30);
				name_15.setMaxLength(1);
				name_15.addValidator(letterEntryValidator);
				formAbsoluteLayout.addComponent(name_15,
						"top:79.0px;left:523.0px;");
				
				//dateLabel
				dateLabel = new Label();
				dateLabel.setCaption(getMessages().getString("birthdate")); //$NON-NLS-1$
				dateLabel.setWidth("15px"); 
				formAbsoluteLayout.addComponent(dateLabel, 
						"top:141.0px;left:10.0px;"); 
				//day_1
				day_1 = new TextField();
				day_1.setCaption(getMessages().getString("day"));
				day_1.setImmediate(true);
				day_1.setTextChangeEventMode(TextChangeEventMode.EAGER);
				day_1.addListener(new TextChangeListener() {
					
					/**
					 * 
					 */
					private static final long serialVersionUID = 1L;

					@Override
					public void textChange(TextChangeEvent event) {
						// TODO Auto-generated method stub
						if(event.getText().length()>0){
							day_2.focus();
						}
					}
				});
				day_1.setWidth("32px"); 
				day_1.setHeight("-1px"); 
				day_1.addValidator(numericEntryValidator);
				day_1.setTabIndex(31);
				day_1.setMaxLength(1);
				day_1.setRequired(true);
				formAbsoluteLayout.addComponent(day_1, 
						"top:126.0px;left:151.0px;"); 
			
				//day_2
				day_2 = new TextField();
				day_2.setCaption(getMessages().getString("day"));
				day_2.setImmediate(true);
				day_2.setTextChangeEventMode(TextChangeEventMode.EAGER);
				day_2.addListener(new TextChangeListener() {
					
					/**
					 * 
					 */
					private static final long serialVersionUID = 1L;

					@Override
					public void textChange(TextChangeEvent event) {
						// TODO Auto-generated method stub
						if(event.getText().length()>0){
							month_1.focus();
						}
					}
				});
				day_2.setWidth("32px");
				day_2.setHeight("-1px"); 
				day_2.addValidator(numericEntryValidator);
				day_2.setTabIndex(32);
				day_2.setMaxLength(1);
				day_2.setRequired(true);
				formAbsoluteLayout.addComponent(day_2, 
						"top:126.0px;left:181.0px;"); 
				
				//month_1
				month_1 = new TextField();
				month_1.setCaption(getMessages().getString("month"));
				month_1.setImmediate(true);
				month_1.setTextChangeEventMode(TextChangeEventMode.EAGER);
				month_1.addListener(new TextChangeListener() {
					
					/**
					 * 
					 */
					private static final long serialVersionUID = 1L;

					@Override
					public void textChange(TextChangeEvent event) {
						// TODO Auto-generated method stub
						if(event.getText().length()>0){
							month_2.focus();
						}
					}
				});
				month_1.setWidth("32px"); 
				month_1.setHeight("-1px"); 
				month_1.addValidator(numericEntryValidator);
				month_1.setTabIndex(33);
				month_1.setMaxLength(1);
				month_1.setRequired(true);
				formAbsoluteLayout.addComponent(month_1, 
						"top:126.0px;left:244.0px;"); 
				//month_2
				month_2 = new TextField();
				month_2.setCaption(getMessages().getString("month"));
				month_2.setImmediate(true);
				month_2.setTextChangeEventMode(TextChangeEventMode.EAGER);
				month_2.addListener(new TextChangeListener() {
					
					/**
					 * 
					 */
					private static final long serialVersionUID = 1L;

					@Override
					public void textChange(TextChangeEvent event) {
						// TODO Auto-generated method stub
						if(event.getText().length()>0){
							year_1.focus();
						}
					}
				});
				month_2.setWidth("32px"); 
				month_2.setHeight("-1px"); 
				month_2.addValidator(numericEntryValidator);
				month_2.setMaxLength(1);
				month_2.setRequired(true);
				month_2.setTabIndex(34);
				formAbsoluteLayout.addComponent(month_2, 
						"top:126.0px;left:275.0px;"); 
				//year_1
				year_1 = new TextField();
				year_1.setCaption(getMessages().getString("year"));
				year_1.setImmediate(true);
				year_1.setTextChangeEventMode(TextChangeEventMode.EAGER);
				year_1.addListener(new TextChangeListener() {
					
					/**
					 * 
					 */
					private static final long serialVersionUID = 1L;

					@Override
					public void textChange(TextChangeEvent event) {
						// TODO Auto-generated method stub
						if(event.getText().length()>0){
							year_2.focus();
						}
					}
				});
				year_1.setWidth("32px"); 
				year_1.setHeight("-1px"); 
				year_1.addValidator(numericEntryValidator);
				year_1.setTabIndex(35);
				year_1.setMaxLength(1);
				year_1.setRequired(true);
				formAbsoluteLayout.addComponent(year_1, 
						"top:126.0px;left:339.0px;"); 
				//year_2
				year_2 = new TextField();
				year_2.setCaption(getMessages().getString("year"));
				year_2.setImmediate(true);
				year_2.setTextChangeEventMode(TextChangeEventMode.EAGER);
				year_2.addListener(new TextChangeListener() {
					
					/**
					 * 
					 */
					private static final long serialVersionUID = 1L;

					@Override
					public void textChange(TextChangeEvent event) {
						// TODO Auto-generated method stub
						if(event.getText().length()>0){
							year_3.focus();
						}
					}
				});
				year_2.setWidth("32px"); 
				year_2.setHeight("-1px"); 
				year_2.addValidator(numericEntryValidator);
				year_2.setTabIndex(36);
				year_2.setMaxLength(1);
				year_2.setRequired(true);
				formAbsoluteLayout.addComponent(year_2, 
						"top:126.0px;left:370.0px;"); 
				//year_3
				year_3 = new TextField();
				year_3.setCaption(getMessages().getString("year"));
				year_3.setImmediate(true);
				year_3.setTextChangeEventMode(TextChangeEventMode.EAGER);
				year_3.addListener(new TextChangeListener() {
					
					/**
					 * 
					 */
					private static final long serialVersionUID = 1L;

					@Override
					public void textChange(TextChangeEvent event) {
						// TODO Auto-generated method stub
						if(event.getText().length()>0){
							year_4.focus();
						}
					}
				});
				year_3.setWidth("32px"); 
				year_3.setHeight("-1px"); 
				year_3.addValidator(numericEntryValidator);
				year_3.setTabIndex(37);
				year_3.setMaxLength(1);
				year_3.setRequired(true);
				formAbsoluteLayout.addComponent(year_3, 
						"top:126.0px;left:401.0px;"); 
				//year_4
				year_4 = new TextField();
				year_4.setCaption(getMessages().getString("year"));
				year_4.setImmediate(true);
				year_4.setTextChangeEventMode(TextChangeEventMode.EAGER);
				year_4.addListener(new TextChangeListener() {
					
					/**
					 * 
					 */
					private static final long serialVersionUID = 1L;

					@Override
					public void textChange(TextChangeEvent event) {
						if(event.getText().length()>0){
							//sendButton.focus();
						}
					}
				});
				year_4.setWidth("32px"); 
				year_4.setHeight("-1px"); 
				year_4.addValidator(numericEntryValidator);
				year_4.setTabIndex(38);
				year_4.setMaxLength(1);
				year_4.setRequired(true);
				formAbsoluteLayout.addComponent(year_4, 
								"top:126.0px;left:433.0px;");
		return formAbsoluteLayout;
	}

	@Override
	public List<String> getNamesValues() {
		List<String> namesValues = new ArrayList<String>(
				Arrays.asList(name_1.getValue().toString(),
						name_2.getValue().toString(),
						name_3.getValue().toString(),
						name_4.getValue().toString(),
						name_5.getValue().toString(),
						name_6.getValue().toString(),
						name_7.getValue().toString(),
						name_8.getValue().toString(),
						name_9.getValue().toString(),
						name_10.getValue().toString(),
						name_11.getValue().toString(),
						name_12.getValue().toString(),
						name_13.getValue().toString(),
						name_14.getValue().toString(),
						name_15.getValue().toString()
						));
		return namesValues;
	}

	@Override
	public List<String> getFirstnamesValues() {
		List<String> firstnamesValues = new ArrayList<String>(
				Arrays.asList(vorname_1.getValue().toString(),
						vorname_2.getValue().toString(),
						vorname_3.getValue().toString(),
						vorname_4.getValue().toString(),
						vorname_5.getValue().toString(),
						vorname_6.getValue().toString(),
						vorname_7.getValue().toString(),
						vorname_8.getValue().toString(),
						vorname_9.getValue().toString(),
						vorname_10.getValue().toString(),
						vorname_11.getValue().toString(),
						vorname_12.getValue().toString(),
						vorname_13.getValue().toString(),
						vorname_14.getValue().toString(),
						vorname_15.getValue().toString()
						));
		return firstnamesValues;
	}

	@Override
	public void doNormalizeBirthDate() {
	
		if(day_1.getValue() == null | day_1.getValue() == ""){
				day_1.setValue("0");
		}
		if(day_2.getValue() == null | day_2.getValue() == ""){
				day_2.setValue("1");
		}
		if(month_1.getValue() == null | month_1.getValue() == ""){
				month_1.setValue("0");
		}
		if(month_2.getValue() == null | month_2.getValue() == ""){
				month_2.setValue("1");
		}
		if(year_1.getValue() == null | year_1.getValue() == ""){
				year_1.setValue("1");
		}
		if(year_2.getValue() == null | year_2.getValue() == ""){
				year_2.setValue("9");
		}
		if(year_3.getValue() == null | year_3.getValue() == ""){
				year_3.setValue("7");
		}
		if(year_4.getValue() == null | year_4.getValue() == ""){
				year_4.setValue("0");
		}
	}
	
	@Override
	public List<Integer> getDateOfBirth(){
		List<Integer> dateOfBirth = new ArrayList<Integer>(
		Arrays.asList(Integer.parseInt(day_1.getValue().toString()),
					Integer.parseInt(day_2.getValue().toString()),
					Integer.parseInt(month_1.getValue().toString()),
					Integer.parseInt(month_2.getValue().toString()),
					Integer.parseInt(year_1.getValue().toString()),
					Integer.parseInt(year_2.getValue().toString()),
					Integer.parseInt(year_3.getValue().toString()),
					Integer.parseInt(year_4.getValue().toString())
				));
		return dateOfBirth;
	}

	@Override
	public void setCurrentLocaleValue(String currentLocaleValue) {
		// TODO Auto-generated method stub
		
	}
	
	public void showMiseEnNombre(PersonBean individum){
		
		name_1.setCaption( individum.getNameLettersMapping().get(0)==0 ? "" :  String.valueOf(individum.getNameLettersMapping().get(0)));
		name_2.setCaption(individum.getNameLettersMapping().get(1)==0 ? "" :   String.valueOf(individum.getNameLettersMapping().get(1)));
		name_3.setCaption(individum.getNameLettersMapping().get(2)==0 ? "" :   String.valueOf(individum.getNameLettersMapping().get(2)));
		name_4.setCaption(individum.getNameLettersMapping().get(3)==0 ? "" : String.valueOf(individum.getNameLettersMapping().get(3)));
		name_5.setCaption(individum.getNameLettersMapping().get(4)==0 ? "" : String.valueOf(individum.getNameLettersMapping().get(4)));
		name_6.setCaption(individum.getNameLettersMapping().get(5)==0 ? "" : String.valueOf(individum.getNameLettersMapping().get(5)));
		name_7.setCaption(individum.getNameLettersMapping().get(6)==0 ? "" : String.valueOf(individum.getNameLettersMapping().get(6)));
		name_8.setCaption(individum.getNameLettersMapping().get(7)==0 ? "" : String.valueOf(individum.getNameLettersMapping().get(7)));
		name_9.setCaption(individum.getNameLettersMapping().get(8)==0 ? "" : String.valueOf(individum.getNameLettersMapping().get(8)));
		name_10.setCaption(individum.getNameLettersMapping().get(9)==0 ? "" : String.valueOf(individum.getNameLettersMapping().get(9)));
		name_11.setCaption(individum.getNameLettersMapping().get(10)==0 ? "" : String.valueOf(individum.getNameLettersMapping().get(10)));
		name_12.setCaption(individum.getNameLettersMapping().get(11)==0 ? "" : String.valueOf(individum.getNameLettersMapping().get(11)));
		name_13.setCaption(individum.getNameLettersMapping().get(12)==0 ? "" : String.valueOf(individum.getNameLettersMapping().get(12)));
		name_14.setCaption(individum.getNameLettersMapping().get(13)==0 ? "" : String.valueOf(individum.getNameLettersMapping().get(13)));
		name_15.setCaption(individum.getNameLettersMapping().get(14)==0 ? "" : String.valueOf(individum.getNameLettersMapping().get(14)));
		
		vorname_1.setCaption(individum.getFirstnameLettersMapping().get(0)==0 ? "" : String.valueOf(individum.getFirstnameLettersMapping().get(0)));
		vorname_2.setCaption(individum.getFirstnameLettersMapping().get(1)==0 ? "" : String.valueOf(individum.getFirstnameLettersMapping().get(1)));
		vorname_3.setCaption(individum.getFirstnameLettersMapping().get(2)==0 ? "" : String.valueOf(individum.getFirstnameLettersMapping().get(2)));
		vorname_4.setCaption(individum.getFirstnameLettersMapping().get(3)==0 ? "" : String.valueOf(individum.getFirstnameLettersMapping().get(3)));
		vorname_5.setCaption(individum.getFirstnameLettersMapping().get(4)==0 ? "" : String.valueOf(individum.getFirstnameLettersMapping().get(4)));
		vorname_6.setCaption(individum.getFirstnameLettersMapping().get(5)==0 ? "" : String.valueOf(individum.getFirstnameLettersMapping().get(5)));
		vorname_7.setCaption(individum.getFirstnameLettersMapping().get(6)==0 ? "" : String.valueOf(individum.getFirstnameLettersMapping().get(6)));
		vorname_8.setCaption(individum.getFirstnameLettersMapping().get(7)==0 ? "" : String.valueOf(individum.getFirstnameLettersMapping().get(7)));
		vorname_9.setCaption(individum.getFirstnameLettersMapping().get(8)==0 ? "" : String.valueOf(individum.getFirstnameLettersMapping().get(8)));
		vorname_10.setCaption(individum.getFirstnameLettersMapping().get(9)==0 ? "" : String.valueOf(individum.getFirstnameLettersMapping().get(9)));
		vorname_11.setCaption(individum.getFirstnameLettersMapping().get(10)==0 ? "" : String.valueOf(individum.getFirstnameLettersMapping().get(10)));
		vorname_12.setCaption(individum.getFirstnameLettersMapping().get(11)==0 ? "" : String.valueOf(individum.getFirstnameLettersMapping().get(11)));
		vorname_13.setCaption(individum.getFirstnameLettersMapping().get(12)==0 ? "" : String.valueOf(individum.getFirstnameLettersMapping().get(12)));
		vorname_14.setCaption(individum.getFirstnameLettersMapping().get(13)==0 ? "" : String.valueOf(individum.getFirstnameLettersMapping().get(13)));
		vorname_15.setCaption(individum.getFirstnameLettersMapping().get(14)==0 ? "" : String.valueOf(individum.getFirstnameLettersMapping().get(14)));

	}
}
